home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / cert / trk3_eg / cmdialog / cmdialog.frm (.txt) next >
Encoding:
Visual Basic Form  |  1994-12-01  |  2.5 KB  |  95 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   4020
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1770
  7.    ClientWidth     =   7365
  8.    Height          =   4710
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4020
  12.    ScaleWidth      =   7365
  13.    Top             =   1140
  14.    Width           =   7485
  15.    Begin CommandButton cmdExit 
  16.       Caption         =   "E&xit"
  17.       Height          =   495
  18.       Left            =   5880
  19.       TabIndex        =   2
  20.       Top             =   3000
  21.       Width           =   1215
  22.    End
  23.    Begin TextBox Text1 
  24.       Height          =   3975
  25.       Left            =   0
  26.       TabIndex        =   1
  27.       Top             =   0
  28.       Width           =   5535
  29.    End
  30.    Begin CommandButton cmdOpen 
  31.       Caption         =   "&Open"
  32.       Height          =   495
  33.       Left            =   5880
  34.       TabIndex        =   0
  35.       Top             =   360
  36.       Width           =   1215
  37.    End
  38.    Begin CommonDialog CMDialog1 
  39.       Left            =   6120
  40.       Top             =   1320
  41.    End
  42.    Begin Menu mnuFile 
  43.       Caption         =   "&File"
  44.       Begin Menu mnuOpen 
  45.          Caption         =   "&Open"
  46.       End
  47.       Begin Menu mnuSep 
  48.          Caption         =   "-"
  49.       End
  50.       Begin Menu mnuexit 
  51.          Caption         =   "E&xit"
  52.       End
  53.    End
  54. Option Explicit
  55. Sub cmdExit_Click ()
  56.     End
  57. End Sub
  58. Sub cmdOpen_Click ()
  59. Dim fname As String
  60. Dim fhandle As Integer
  61. On Error GoTo ErrOpen
  62. 'Set properties for Commaon Dialog
  63. CMDialog1.CancelError = True    'Creates a run time error if hit cancel
  64. CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt"
  65. CMDialog1.FilterIndex = 2   'Uses text files as default filter
  66. CMDialog1.InitDir = "C:\VB5Day\Labs"    'Set default path for Dialog box
  67. 'Display the File Open Dialog Box
  68. CMDialog1.Action = 1
  69. 'Capture file name selected
  70. fname = CMDialog1.Filename
  71. 'Load file into text box
  72. fhandle = FreeFile      'Find available handle number
  73. Open fname For Input As fhandle     'Open as sequential file
  74. text1.Text = Input$(LOF(fhandle), fhandle)
  75. Exit Sub
  76. ErrOpen:
  77. Select Case Err
  78. Case 32755
  79.     Exit Sub
  80. Case Else
  81.     Dim msg As String
  82.     msg$ = "An unexpected error has occurred:" & Chr$(10)
  83.     msg$ = msg$ & "Error#:  " & Err & Chr$(10)
  84.     msg$ = msg$ & Error$
  85.     MsgBox msg$, 48, "Error"
  86.     End
  87. End Select
  88. End Sub
  89. Sub mnuexit_Click ()
  90.     End
  91. End Sub
  92. Sub mnuOpen_Click ()
  93.     Call cmdOpen_Click
  94. End Sub
  95.